<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <style>
      .father {
        position: relative;
        width: 600px;
        height: 400px;
        background: #ccc;
      }
      .son {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        width: 200px;
        height: 100px;
        background: red;
        margin: auto;
      }

      .icon-menu {
        display: inline-block;
        width: 24px;
        height: 4px;
        border-top: 14px double;
        border-bottom: 5px solid;
      }
      .icon-close {
        position: relative;
        width: 24px;
        height: 24px;
      }
      /* .icon-close::before, .icon-close::after {
        position: absolute;
        left: 10px;
        content: ' ';
        height: 25px;
        width: 4px;
        background: black;
      }
      .icon-close::before {
        transform: rotate(45deg);
      }
      .icon-close::after {
        transform: rotate(-45deg);
      } */
      .icon-close::after {
        content: '\2716';
        font-size: 26px;
        text-align: center;
        line-height: 24px;
        color: black;
      }
    </style>
    <div class="father">
      <div class="son"></div>
    </div>

    <span class="icon-close" id="icon"></span>
    <script>
      const iconDom = document.querySelector('#icon');
      iconDom.onclick = function (ev) {
        if (ev.target.classList.contains('icon-close')) {
          ev.target.classList.replace('icon-close', 'icon-menu');
        } else if (ev.target.classList.contains('icon-menu')) {
          ev.target.classList.replace('icon-menu', 'icon-close');
        }
      };
    </script>
  </body>
</html>
